﻿using System;
using TraditionalMalteseCuisine.App_Code.Functions;

namespace TraditionalMalteseCuisine
{
    public partial class ForgotPassword : System.Web.UI.Page
    {
        #region Page Load
        protected void Page_Load(object sender, EventArgs e)
        {

        }
        #endregion


        #region Buttons
        protected void btnSendEMail_Click(object sender, EventArgs e)
        {
            lblMessage.Visible = false;

            string email = txtEMail.Text;

            if (Site_Functions.DoesEmailExists(email))
            {
                Site_Functions.SendResetPasswordEMail(email);

                txtEMail.Text = string.Empty;

                lblMessage.Visible = true;
                
                Response.AddHeader("REFRESH", string.Format("5;URL=signin.aspx?continueon=profile.aspx?user={0}", Site_Functions.GetSiteMemberDetailsUsingEMail(email).ID));
            }
            else
            {
                csvEMailDoesNotExists.IsValid = false;
            }
        }
        #endregion
    }
}